package com.joysuch.wwyt.bp.entity.inspect;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.bp.bean.inspect.BpPlanAppTimeDto;
import com.joysuch.wwyt.bp.bean.inspect.StaffBean;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 巡检-检查计划管理
 */
@Data
@Entity
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Table(name = "WWYT_BP_INSPECT_PLAN")
@SQLDelete(sql = "update WWYT_BP_INSPECT_PLAN set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BP_INSPECT_PLAN set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class BpInspectPlan implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @ApiModelProperty("主键ID")
    private Long id;

    @ApiModelProperty("检查计划名称")
    private String name;

    @ApiModelProperty("点位数量")
    private Integer count;

    @ApiModelProperty("巡检周期")
    private String inspectPeriod;

    @ApiModelProperty("审核状态")
    @JsonIgnore
    private String verifyStatus;

    @ApiModelProperty("启用状态")
    private String initiateStatus;

    @ApiModelProperty("检查类型id")
    private Long inspectTypeId;

    @ApiModelProperty("检查全部点位: 是/否")
    private String checkAllPoint;

    @ApiModelProperty("检查周期类型")
    private String periodType;

    @ApiModelProperty("周期设置")
    private String periodSetting;

    @ApiModelProperty("周期起始时间")
    private String periodStartTime;

    @ApiModelProperty("周期结束时间--目前只针对--几小时几次")
    @JsonFormat(timezone = "GMT+8")
    private LocalTime periodEndTime;

    @ApiModelProperty("检查日期-计算得出")
    private LocalDate checkDate;

    @ApiModelProperty("检查时间-计算得出")
    private LocalTime checkTime;

//    @ApiModelProperty("检查点停留最小时间(分)")
//    private Integer stopMinTime;

    @ApiModelProperty("检查时限(分钟)")
    private Integer checkLimit;

    @ApiModelProperty("异常通知(部门)")
    private Long notifyDepartId;

    @Transient
    @ApiModelProperty("异常通知(部门)名称")
    private String notifyDepartName;

    @ApiModelProperty("间隔(分钟)-按周期-计算两次任务之间的间隔")
    private Integer minuteDuration;

    @ApiModelProperty("允许开始执行误差时间-分钟")
    private String permitDeviationTime;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("检查者人员ids")
    private String inspectStaffIds;

    @ApiModelProperty("检查者人员ids-Long[]")
    @Transient
    private StaffBean[] staffBeans;

    @ApiModelProperty("检查者部门ids")
    private String inspectDepartIds;

    @ApiModelProperty("检查者部门ids-Long[]")
    @Transient
    private Long[] inspectDepartResultIds;

    @ApiModelProperty("检查者岗位ids")
    private String inspectPositionIds;

    @ApiModelProperty("检查者岗位ids-Long[]")
    @Transient
    private Long[] inspectPositionResultIds;

    @ApiModelProperty("检查点集合")
    @Transient
    private List<BpInspectPlanCheckPoint> pointList;

    @ApiModelProperty("检查项目总数")
    @Transient
    private int itemSum;

    @ApiModelProperty("隐患总数")
    @Transient
    private int hideDangerSum;

    @ApiModelProperty("已完成的计划关联的记录id")
    @Transient
    private Long recordId;

    @ApiModelProperty("app/v2 今日待办-巡检时段")
    @Transient
    private List<BpPlanAppTimeDto> checkTimeList;

    @ApiModelProperty("app/v2 今日待办-巡检周期")
    @Transient
    private String appInspectPeriod;

    @ApiModelProperty("是否是跨天任务--只针对几小时几次 默认false")
    private Boolean crossDayTask;

    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    private Long createBy;

    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    private java.time.LocalDateTime createTime;

    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    @JsonIgnore
    private Long updateBy;

    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    private java.time.LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;
}
